package org.wdhl.xzc.wdhlxzctool.mixin;

import net.minecraft.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(xyz.pixelatedw.mineminenomi.api.abilities.components.DealDamageComponent.class)
public class DealDamageComponentMixin {
    
    @Inject(method = "hurtTarget(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/LivingEntity;F)Z", 
            at = @At("HEAD"), 
            cancellable = true, 
            remap = false)
    private void onHurtTarget(LivingEntity attacker, LivingEntity target, float damage, CallbackInfoReturnable<Boolean> cir) {
        if (attacker == null) {
            cir.setReturnValue(false);
            cir.cancel();
            System.out.println("问题：[DealDamageComponentMixin] attacker 是 null 修复了！");
        }
        if (target == null) {
            cir.setReturnValue(false);
            cir.cancel();
            System.out.println("问题：[DealDamageComponentMixin] target 是 null 攻击者的伤害调用修复了！");
        }
    }
}